import 'package:sharesdk_plugin/sharesdk_defines.dart';
import 'package:sharesdk_plugin/sharesdk_interface.dart';
import 'package:sharesdk_plugin/sharesdk_map.dart';

class ShareUtil {

  static shareImg({
    String? title, 
    String? description, 
    String? image, 
    String? url, 
    String shareType = '0'
  }) {
    SSDKMap params = SSDKMap()..setGeneral(
      title ?? '', description ?? '', [image], image ?? '', "", url ?? '', "",  "", "", "",
      SSDKContentTypes.image
    );

    SharesdkPlugin.share(
      shareType == '0' ? ShareSDKPlatforms.wechatSession :
      shareType == '1' ? ShareSDKPlatforms.wechatTimeline :
      shareType == '2' ? ShareSDKPlatforms.qq :
      shareType == '3' ? ShareSDKPlatforms.sina : ShareSDKPlatforms.wechatSession,
      params, (
        SSDKResponseState state, 
        dynamic userdata, 
        dynamic contentEntity, 
        SSDKError error
      ) {
      }
    );
  }



  static shareUrl({
    String? title, 
    String? description, 
    String? image, 
    String? url, 
    String shareType = '0'
  }) {
    SSDKMap params = SSDKMap()..setGeneral(
      title ?? '', description ?? '', [image], image ?? '', "", url ?? '', "",  "", "", "",
      SSDKContentTypes.webpage
    );
    SharesdkPlugin.share(
      shareType == '0' ? ShareSDKPlatforms.wechatSession :
      shareType == '1' ? ShareSDKPlatforms.wechatTimeline :
      shareType == '2' ? ShareSDKPlatforms.qq :
      shareType == '3' ? ShareSDKPlatforms.sina : ShareSDKPlatforms.wechatSession,
      params,// wechatSession
        (SSDKResponseState state, dynamic userdata, dynamic contentEntity,
            SSDKError error) {
    });
  }

}